import { ChangeMemberMenuParams, PutUserStateParam, UserListParam } from "@Tea/model"
import { UserRepository } from "../repo/UserRepository"
import { UserMenuRepository } from "../repo/UserMenuRepository"
import { LoggedInRequest } from "../types"
import { TokenObj } from "../dao/Token"

export class MemberMangeContext {
  private static inst: MemberMangeContext
  private userMenuRepo: UserMenuRepository = UserMenuRepository.getInstance()

  // 单例
  public static getInstance() {
    if (!MemberMangeContext.inst) {
      MemberMangeContext.inst = new MemberMangeContext()
    }

    return MemberMangeContext.inst
  }

  async chagneMemberMenu(params: ChangeMemberMenuParams, handerId: TokenObj["userId"]) {
    const delResult = await this.userMenuRepo.deleteUserAllMenu(params.userId)
    const insertResult = await this.userMenuRepo.addUserMenu(params, handerId)
    
    return [delResult, insertResult]
  }
}